1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.TabBar;
26 
27 private import adw.TabPage;
28 private import adw.TabView;
29 private import adw.c.functions;
30 public  import adw.c.types;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 private import gobject.Value;
35 private import gtk.AccessibleIF;
36 private import gtk.AccessibleT;
37 private import gtk.BuildableIF;
38 private import gtk.BuildableT;
39 private import gtk.ConstraintTargetIF;
40 private import gtk.ConstraintTargetT;
41 private import gtk.Widget;
42 private import std.algorithm;
43 
44 
45 /**
46  * A tab bar for [class@TabView].
47  * 
48  * <picture>
49  * <source srcset="tab-bar-dark.png" media="(prefers-color-scheme: dark)">
50  * <img src="tab-bar.png" alt="tab-bar">
51  * </picture>
52  * 
53  * The `AdwTabBar` widget is a tab bar that can be used with conjunction with
54  * `AdwTabView`.
55  * 
56  * `AdwTabBar` can autohide and can optionally contain action widgets on both
57  * sides of the tabs.
58  * 
59  * When there's not enough space to show all the tabs, `AdwTabBar` will scroll
60  * them. Pinned tabs always stay visible and aren't a part of the scrollable
61  * area.
62  * 
63  * ## CSS nodes
64  * 
65  * `AdwTabBar` has a single CSS node with name `tabbar`.
66  *
67  * Since: 1.0
68  */
69 public class TabBar : Widget
70 {
71 	/** the main Gtk struct */
72 	protected AdwTabBar* adwTabBar;
73 
74 	/** Get the main Gtk struct */
75 	public AdwTabBar* getTabBarStruct(bool transferOwnership = false)
76 	{
77 		if (transferOwnership)
78 			ownedRef = false;
79 		return adwTabBar;
80 	}
81 
82 	/** the main Gtk struct as a void* */
83 	protected override void* getStruct()
84 	{
85 		return cast(void*)adwTabBar;
86 	}
87 
88 	/**
89 	 * Sets our main struct and passes it to the parent class.
90 	 */
91 	public this (AdwTabBar* adwTabBar, bool ownedRef = false)
92 	{
93 		this.adwTabBar = adwTabBar;
94 		super(cast(GtkWidget*)adwTabBar, ownedRef);
95 	}
96 
97 
98 	/** */
99 	public static GType getType()
100 	{
101 		return adw_tab_bar_get_type();
102 	}
103 
104 	/**
105 	 * Creates a new `AdwTabBar`.
106 	 *
107 	 * Returns: the newly created `AdwTabBar`
108 	 *
109 	 * Since: 1.0
110 	 *
111 	 * Throws: ConstructionException GTK+ fails to create the object.
112 	 */
113 	public this()
114 	{
115 		auto __p = adw_tab_bar_new();
116 
117 		if(__p is null)
118 		{
119 			throw new ConstructionException("null returned by new");
120 		}
121 
122 		this(cast(AdwTabBar*) __p);
123 	}
124 
125 	/**
126 	 * Gets whether the tabs automatically hide.
127 	 *
128 	 * Returns: whether the tabs automatically hide
129 	 *
130 	 * Since: 1.0
131 	 */
132 	public bool getAutohide()
133 	{
134 		return adw_tab_bar_get_autohide(adwTabBar) != 0;
135 	}
136 
137 	/**
138 	 * Gets the widget shown after the tabs.
139 	 *
140 	 * Returns: the widget shown after the tabs
141 	 *
142 	 * Since: 1.0
143 	 */
144 	public Widget getEndActionWidget()
145 	{
146 		auto __p = adw_tab_bar_get_end_action_widget(adwTabBar);
147 
148 		if(__p is null)
149 		{
150 			return null;
151 		}
152 
153 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
154 	}
155 
156 	/**
157 	 * Gets whether tabs expand to full width.
158 	 *
159 	 * Returns: whether tabs expand to full width.
160 	 *
161 	 * Since: 1.0
162 	 */
163 	public bool getExpandTabs()
164 	{
165 		return adw_tab_bar_get_expand_tabs(adwTabBar) != 0;
166 	}
167 
168 	/**
169 	 * Gets whether tabs use inverted layout.
170 	 *
171 	 * Returns: whether tabs use inverted layout
172 	 *
173 	 * Since: 1.0
174 	 */
175 	public bool getInverted()
176 	{
177 		return adw_tab_bar_get_inverted(adwTabBar) != 0;
178 	}
179 
180 	/**
181 	 * Gets whether @self is overflowing.
182 	 *
183 	 * Returns: whether @self is overflowing
184 	 *
185 	 * Since: 1.0
186 	 */
187 	public bool getIsOverflowing()
188 	{
189 		return adw_tab_bar_get_is_overflowing(adwTabBar) != 0;
190 	}
191 
192 	/**
193 	 * Gets the widget shown before the tabs.
194 	 *
195 	 * Returns: the widget shown before the tabs
196 	 *
197 	 * Since: 1.0
198 	 */
199 	public Widget getStartActionWidget()
200 	{
201 		auto __p = adw_tab_bar_get_start_action_widget(adwTabBar);
202 
203 		if(__p is null)
204 		{
205 			return null;
206 		}
207 
208 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
209 	}
210 
211 	/**
212 	 * Gets whether the tabs are currently revealed.
213 	 *
214 	 * Returns: whether the tabs are currently revealed
215 	 *
216 	 * Since: 1.0
217 	 */
218 	public bool getTabsRevealed()
219 	{
220 		return adw_tab_bar_get_tabs_revealed(adwTabBar) != 0;
221 	}
222 
223 	/**
224 	 * Gets the tab view @self controls.
225 	 *
226 	 * Returns: the view @self controls
227 	 *
228 	 * Since: 1.0
229 	 */
230 	public TabView getView()
231 	{
232 		auto __p = adw_tab_bar_get_view(adwTabBar);
233 
234 		if(__p is null)
235 		{
236 			return null;
237 		}
238 
239 		return ObjectG.getDObject!(TabView)(cast(AdwTabView*) __p);
240 	}
241 
242 	/**
243 	 * Sets whether the tabs automatically hide.
244 	 *
245 	 * Params:
246 	 *     autohide = whether the tabs automatically hide
247 	 *
248 	 * Since: 1.0
249 	 */
250 	public void setAutohide(bool autohide)
251 	{
252 		adw_tab_bar_set_autohide(adwTabBar, autohide);
253 	}
254 
255 	/**
256 	 * Sets the widget to show after the tabs.
257 	 *
258 	 * Params:
259 	 *     widget = the widget to show after the tabs
260 	 *
261 	 * Since: 1.0
262 	 */
263 	public void setEndActionWidget(Widget widget)
264 	{
265 		adw_tab_bar_set_end_action_widget(adwTabBar, (widget is null) ? null : widget.getWidgetStruct());
266 	}
267 
268 	/**
269 	 * Sets whether tabs expand to full width.
270 	 *
271 	 * Params:
272 	 *     expandTabs = whether to expand tabs
273 	 *
274 	 * Since: 1.0
275 	 */
276 	public void setExpandTabs(bool expandTabs)
277 	{
278 		adw_tab_bar_set_expand_tabs(adwTabBar, expandTabs);
279 	}
280 
281 	/**
282 	 * Sets whether tabs tabs use inverted layout.
283 	 *
284 	 * Params:
285 	 *     inverted = whether tabs use inverted layout
286 	 *
287 	 * Since: 1.0
288 	 */
289 	public void setInverted(bool inverted)
290 	{
291 		adw_tab_bar_set_inverted(adwTabBar, inverted);
292 	}
293 
294 	/**
295 	 * Sets the widget to show before the tabs.
296 	 *
297 	 * Params:
298 	 *     widget = the widget to show before the tabs
299 	 *
300 	 * Since: 1.0
301 	 */
302 	public void setStartActionWidget(Widget widget)
303 	{
304 		adw_tab_bar_set_start_action_widget(adwTabBar, (widget is null) ? null : widget.getWidgetStruct());
305 	}
306 
307 	/**
308 	 * Sets the tab view @self controls.
309 	 *
310 	 * Params:
311 	 *     view = a tab view
312 	 *
313 	 * Since: 1.0
314 	 */
315 	public void setView(TabView view)
316 	{
317 		adw_tab_bar_set_view(adwTabBar, (view is null) ? null : view.getTabViewStruct());
318 	}
319 
320 	/**
321 	 * Sets the supported types for this drop target.
322 	 *
323 	 * Sets up an extra drop target on tabs.
324 	 *
325 	 * This allows to drag arbitrary content onto tabs, for example URLs in a web
326 	 * browser.
327 	 *
328 	 * If a tab is hovered for a certain period of time while dragging the content,
329 	 * it will be automatically selected.
330 	 *
331 	 * The [signal@TabBar::extra-drag-drop] signal can be used to handle the drop.
332 	 *
333 	 * Params:
334 	 *     actions = the supported actions
335 	 *     types = all supported `GType`s that can be dropped
336 	 *
337 	 * Since: 1.0
338 	 */
339 	public void setupExtraDropTarget(GdkDragAction actions, GType[] types)
340 	{
341 		adw_tab_bar_setup_extra_drop_target(adwTabBar, actions, types.ptr, cast(size_t)types.length);
342 	}
343 
344 	/**
345 	 * This signal is emitted when content is dropped onto a tab.
346 	 *
347 	 * The content must be of one of the types set up via
348 	 * [method@TabBar.setup_extra_drop_target].
349 	 *
350 	 * See [signal@Gtk.DropTarget::drop].
351 	 *
352 	 * Params:
353 	 *     page = the page matching the tab the content was dropped onto
354 	 *     value = the `GValue` being dropped
355 	 *
356 	 * Returns: whether the drop was accepted for @page
357 	 *
358 	 * Since: 1.0
359 	 */
360 	gulong addOnExtraDragDrop(bool delegate(TabPage, Value, TabBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
361 	{
362 		return Signals.connect(this, "extra-drag-drop", dlg, connectFlags ^ ConnectFlags.SWAPPED);
363 	}
364 }